package kafka

import (
	"context"
	"im/models"
	"sync"
)

// ActionHandler 函数类型，用于处理不同类型的 Kafka 消息
type ActionHandler func(ctx context.Context, msg *models.CustomKafkaMsg) error

var (
	handlers        = make(map[string]ActionHandler)
	handlersRWMutex sync.RWMutex
)

func Init() {
	NewImProduce()
	NewConsumerClient()
}

// Register 注册
func Register(key string, value ActionHandler) {
	handlersRWMutex.Lock()
	defer handlersRWMutex.Unlock()
	handlers[key] = value
	return
}
